import sympy as sym
import numpy as np

def isinf(expr):
    # SymPy simplified the expr already
    if isinstance(expr, (list, np.ndarray)):
        narr = np.array(expr)
        exprs = np.reshape(narr, (narr.size,))
        for idx in range(exprs.size):
            exprs[idx] = isinf(exprs[idx])
        return exprs.reshape(narr.shape)
    else:
        result = sym.simplify(expr)
        return result == sym.oo 


# Test case 1: Input is symbolic expressions
x = sym.symbols('x')
p = sym.pi
i = sym.oo
n = sym.nan

arr = [
    [p, n , i],
    [n - 1, i + 1 , p - 3]
    ]
result = np.array([
    [False,False,True],
    [False,True,False]
])
# print(isinf(arr))
assert np.array_equal(isinf(arr), result)
